package com.yuyou.weixin.bean;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class Pagination<T> implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	// totalPage
	private int totalPage;
	
	// curPageNO
	private int pageIndex;
	
	// pageSize
	private int pageSize;
	
	// totalRecord
	private int total;
	
	
	// conditions
	private Map<String, Object> conditions;

	// fromRecord
	private int fromRecord;

	// toRecord
	private int toRecord;
	
	private PageParams pageParams;
	
	private Map<String,Object> ext;
	
    /**
     * list
     */
    private List<T> list = Collections.emptyList();

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public void toBePage() {
		this.setTotalPage((this.getTotal() / this.getPageSize()) + (this.getTotal() % this.getPageSize() > 0 ? 1 : 0));
		this.setFromRecord(this.getPageSize() * this.getPageIndex() - this.getPageSize());
		this.setToRecord(this.getPageSize());
	}

	public int getFromRecord() {
		return fromRecord;
	}

	public void setFromRecord(int fromRecord) {
		this.fromRecord = fromRecord;
	}

	public int getToRecord() {
		return toRecord;
	}

	public void setToRecord(int toRecord) {
		this.toRecord = toRecord;
	}

	public Pagination() {
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}





	public int getPageIndex() {
		return this.getPageParams().getPageIndex();
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return this.getPageParams().getPageSize();
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public Map<String, Object> getConditions() {
		return conditions;
	}

	public void setConditions(Map<String, Object> conditions) {
		this.conditions = conditions;
	}

	public PageParams getPageParams() {
		return pageParams;
	}

	public void setPageParams(PageParams pageParams) {
		this.pageParams = pageParams;
	}

	public Map<String, Object> getExt() {
		return ext;
	}

	public void setExt(Map<String, Object> ext) {
		this.ext = ext;
	}

}